package cc.avatar.repository;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

import cc.avatar.model.inventory.InventoryChangeEvent;

public class ActionListener implements ApplicationListener {
    private ProductRepository productRepository;
        
	public void setProductRepository(ProductRepository productRepository) {
		this.productRepository = productRepository;
	}

	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof InventoryChangeEvent){
			productRepository.calculateInventories();
		}
	}
}
